NYS IPM sweet corn pheromone trapping dataset 1993-2022. Data was initially used as a monitoring tool to inform growers about corn pest populations.
PESTS
Read in csv file. Columns Site, USDA Hardiness Zone, Latitude, Longitude, Year, Week, Date, Day, ECB.E, ECB.Z, CEW, FAW, and WBC. Each row is a sampling event at a farm.
Melt data frame to create a row for each observation, creating a column for the pest name and a column for the pest count.
sweet_corn_pest <- read.delim("NYSIPM_Sweet_Corn_1993_2022.csv", sep = ",")
sweet_corn_pest <- sweet_corn_pest %>%
mutate(Date = as.Date(Date, format = '%m/%d/%y')) %>%
mutate(Site = as.factor(Site)) %>%
mutate(USDA.hardiness.Zone = as.factor(USDA.hardiness.Zone)) %>%
mutate(new_col = format(Date, "%j"), .after = Date) %>%
rename(Day = new_col)
sweet_corn_pest_long <- melt(sweet_corn_pest, id.vars = c("Site", "USDA.hardiness.Zone", "Lat", "Long", "Year", "Week", "Date", "Day"), measure.vars = c("ECB.E", "ECB.Z", "CEW", "FAW", "WBC"), variable.name = 'Pest', value.name = 'Count')
head(sweet_corn_pest_long)
## Site USDA.hardiness.Zone Lat Long Year Week Date
## 1 Accord 6a 41°46'56.41"N 74°14'44.28"W 2021 21 2021-05-25
## 2 Accord 6a 41°46'56.41"N 74°14'44.28"W 2021 22 2021-06-01
## 3 Accord 6a 41°46'56.41"N 74°14'44.28"W 2021 23 2021-06-08
## 4 Accord 6a 41°46'56.41"N 74°14'44.28"W 2021 24 2021-06-15
## 5 Accord 6a 41°46'56.41"N 74°14'44.28"W 2021 25 2021-06-22
## 6 Accord 6a 41°46'56.41"N 74°14'44.28"W 2021 26 2021-06-29
## Day Pest Count
## 1 145 ECB.E NA
## 2 152 ECB.E NA
## 3 159 ECB.E NA
## 4 166 ECB.E NA
## 5 173 ECB.E 0
## 6 180 ECB.E 0
Upload csv with latitude and longitude for all sites. There are 89 unique values for sites.
sites <- read.delim("NYSIPM_Sweet_Corn_1993_2022_Sites.csv", sep = ",")
sites <- sites %>%
mutate(Site = as.factor(Site)) %>%
select(-c('X', 'X.1', 'X.2', 'X.3', 'X.4', 'X.5', 'X.6', 'X.7'))
length(levels(sites$Site))
## [1] 89
head(sites)
## Site USDA.hardiness.Zone Lat Lat.Decimal Long
## 1 Accord 6a 41°46'56.41"N 41.78234 74°14'44.28"W
## 2 Accord 6a 41°46'56.41"N 41.78234 74°14'44.28"W
## 3 Adams Center 4b 43°51'52.56"N 43.86460 75°57'53.64"W
## 4 Afton 5b 42°13'57.32"N 42.23259 75°31'3.54"W
## 5 Albion 6a NA
## 6 Amsterdam 5a 43° 1'18.48"N 43.02180 74°10'48.72"W
## Long.Decimal
## 1 -74.24563
## 2 -74.24563
## 3 -75.96490
## 4 -75.51765
## 5 NA
## 6 -74.18020
sites_with_coord <- sites %>% drop_na()
mapview(sites_with_coord, xcol = "Long.Decimal", ycol = "Lat.Decimal", crs = 4269, grid = FALSE)
Create initial visualizations of the pest count data. Exploring differences in years, species, and sites.
Pest Counts 1993-2022, Faceted by Species
Each species shows different patterns in abundance over time. ECB has decreased over time, while CEW, FAW, and WBC have increased.
sweet_corn_pest_long %>%
ggplot(aes(Date, Count)) +
geom_line() +
ggtitle('Pest Counts 1993-2022') +
facet_wrap(~ Pest)
## Warning: Removed 2 rows containing missing values (`geom_line()`).
ECB_E Count, Faceted by Year
sweet_corn_pest_long %>%
dplyr::filter(Pest == 'ECB.E') %>%
ggplot(aes(Day, Count)) +
geom_line() +
geom_point(size = 0.25) +
ggtitle('ECB_E Counts 1993-2022') +
facet_wrap(~ Year)
## Warning: Removed 261 rows containing missing values (`geom_line()`).
## Warning: Removed 2872 rows containing missing values (`geom_point()`).
ECB_Z Count, Faceted by Year
sweet_corn_pest_long %>%
dplyr::filter(Pest == 'ECB.Z') %>%
ggplot(aes(Day, Count)) +
geom_line() +
geom_point(size = 0.25) +
ggtitle('ECB_Z Counts 1993-2022') +
facet_wrap(~ Year)
## Warning: Removed 255 rows containing missing values (`geom_line()`).
## Warning: Removed 2881 rows containing missing values (`geom_point()`).
CEW Count, Faceted by Year
sweet_corn_pest_long %>%
dplyr::filter(Pest == 'CEW') %>%
ggplot(aes(Day, Count)) +
geom_line() +
geom_point(size = 0.25) +
ggtitle('CEW Counts 1993-2022') +
facet_wrap(~ Year)
## Warning: Removed 425 rows containing missing values (`geom_line()`).
## Warning: Removed 3488 rows containing missing values (`geom_point()`).
FAW Count, Faceted by Year
sweet_corn_pest_long %>%
dplyr::filter(Pest == 'FAW') %>%
ggplot(aes(Day, Count)) +
geom_line() +
geom_point(size = 0.25) +
ggtitle('FAW Counts 1993-2022') +
facet_wrap(~ Year)
## Warning: Removed 524 rows containing missing values (`geom_line()`).
## Warning: Removed 4093 rows containing missing values (`geom_point()`).
WBC Count, Faceted by Year
sweet_corn_pest_long %>%
dplyr::filter(Pest == 'WBC') %>%
ggplot(aes(Day, Count)) +
geom_line() +
geom_point(size = 0.25) +
ggtitle('WBC Counts 1993-2022') +
facet_wrap(~ Year)
## Warning: Removed 5797 rows containing missing values (`geom_line()`).
## Warning: Removed 7908 rows containing missing values (`geom_point()`).
All Pest Counts, Faceted by Yearr
sweet_corn_pest_long %>%
ggplot(aes(Day, Count, col = Pest)) +
geom_line() +
geom_point(size = 0.25) +
ggtitle('Sweet Corn Pest Counts 1993-2022') +
facet_wrap(~ Year)
## Warning: Removed 7262 rows containing missing values (`geom_line()`).
## Warning: Removed 21242 rows containing missing values (`geom_point()`).
Sweet Corn Pest Count, 1993-1995
sweet_corn_pest_long %>%
dplyr::filter(((Year >= 1993) & (Year <= 1995))) %>%
ggplot(aes(Date, Count, col = Pest)) +
geom_line() +
geom_point(size = 0.25) +
ggtitle('Sweet Corn Pest Counts 1993-1995')
## Warning: Removed 875 rows containing missing values (`geom_line()`).
## Warning: Removed 923 rows containing missing values (`geom_point()`).
Sweet Corn Pest Count, 2020-2022
sweet_corn_pest_long %>%
dplyr::filter(((Year >= 2020) & (Year <= 2022))) %>%
ggplot(aes(Date, Count, col = Pest)) +
geom_line() +
geom_point(size = 0.25) +
ggtitle('Sweet Corn Pest Counts 2020-2022')
## Warning: Removed 63 rows containing missing values (`geom_line()`).
## Warning: Removed 2997 rows containing missing values (`geom_point()`).
sweet_corn_pest_long %>%
dplyr::filter(Pest == 'ECB.E') %>%
ggplot(aes(Date, Count)) +
geom_line(size = 1) +
geom_point(size = 0.5) +
ggtitle('ECB_E Counts 1993-2022 by Site') +
facet_wrap(~ Site)
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## Warning: Removed 6 rows containing missing values (`geom_line()`).
## Warning: Removed 2872 rows containing missing values (`geom_point()`).
sweet_corn_pest_long %>%
dplyr::filter(Pest == 'ECB.Z') %>%
ggplot(aes(Date, Count)) +
geom_line(size = 1) +
geom_point(size = 0.5) +
ggtitle('ECB_Z Counts 1993-2022 by Site') +
facet_wrap(~ Site)
## Warning: Removed 6 rows containing missing values (`geom_line()`).
## Warning: Removed 2881 rows containing missing values (`geom_point()`).
sweet_corn_pest_long %>%
dplyr::filter(Pest == 'CEW') %>%
ggplot(aes(Date, Count)) +
geom_line(size = 1) +
geom_point(size = 0.5) +
ggtitle('CEW Counts 1993-2022 by Site') +
facet_wrap(~ Site)
## Warning: Removed 6 rows containing missing values (`geom_line()`).
## Warning: Removed 3488 rows containing missing values (`geom_point()`).
sweet_corn_pest_long %>%
dplyr::filter(Pest == 'FAW') %>%
ggplot(aes(Date, Count)) +
geom_line(size = 1) +
geom_point(size = 0.5) +
ggtitle('FAW Counts 1993-2022 by Site') +
facet_wrap(~ Site)
## Warning: Removed 9 rows containing missing values (`geom_line()`).
## Warning: Removed 4093 rows containing missing values (`geom_point()`).
sweet_corn_pest_long %>%
dplyr::filter(Pest == 'WBC') %>%
ggplot(aes(Date, Count)) +
geom_line(size = 1) +
geom_point(size = 0.5) +
ggtitle('WBC Counts 1993-2022 by Site') +
facet_wrap(~ Site)
## Warning: Removed 9 rows containing missing values (`geom_line()`).
## Warning: Removed 7908 rows containing missing values (`geom_point()`).
sweet_corn_pest_long %>%
replace(is.na(sweet_corn_pest_long), 0) %>%
dplyr::filter(Pest == 'ECB.E') %>%
group_by(Year) %>%
summarise(Total = sum(Count)) %>%
ggplot(aes(x = Year, y = Total)) +
geom_bar(stat = 'identity') +
ggtitle('ECB.E Counts 1993-2022')
sweet_corn_pest_long %>%
replace(is.na(sweet_corn_pest_long), 0) %>%
dplyr::filter(Pest == 'ECB.Z') %>%
group_by(Year) %>%
summarise(Total = sum(Count)) %>%
ggplot(aes(x = Year, y = Total)) +
geom_bar(stat = 'identity') +
ggtitle('ECB.Z Counts 1993-2022')
sweet_corn_pest_long %>%
replace(is.na(sweet_corn_pest_long), 0) %>%
dplyr::filter(Pest == 'CEW') %>%
group_by(Year) %>%
summarise(Total = sum(Count)) %>%
ggplot(aes(x = Year, y = Total)) +
geom_bar(stat = 'identity') +
ggtitle('CEW Counts 1993-2022')
sweet_corn_pest_long %>%
replace(is.na(sweet_corn_pest_long), 0) %>%
dplyr::filter(Pest == 'FAW') %>%
group_by(Year) %>%
summarise(Total = sum(Count)) %>%
ggplot(aes(x = Year, y = Total)) +
geom_bar(stat = 'identity') +
ggtitle('FAW Counts 1993-2022')
sweet_corn_pest_long %>%
replace(is.na(sweet_corn_pest_long), 0) %>%
dplyr::filter(Pest == 'WBC') %>%
group_by(Year) %>%
summarise(Total = sum(Count)) %>%
ggplot(aes(x = Year, y = Total)) +
geom_bar(stat = 'identity') +
ggtitle('WBC Counts 1993-2022')